// license-header java merge-point
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 */
package fr.upstlse.glre.business.service.depot;

import java.util.Collection;

import fr.upstlse.glre.business.domain.depot.Document;
import fr.upstlse.glre.business.domain.depot.DocumentDao;
import fr.upstlse.glre.business.domain.depot.Libelle;
import fr.upstlse.glre.business.vo.depot.DocumentVO;
import fr.upstlse.glre.business.vo.depot.LibelleVO;

/**
 * @see fr.upstlse.glre.business.service.depot.DocumentService
 */
public class DocumentServiceImpl
    extends fr.upstlse.glre.business.service.depot.DocumentServiceBase
{

	/**
     * @see fr.upstlse.glre.business.service.depot.DocumentService#addDocument(fr.upstlse.glre.business.vo.depot.DocumentVO)
     */
    protected long handleAddDocument(fr.upstlse.glre.business.vo.depot.DocumentVO pDocumentVO)
        throws java.lang.Exception
    {
    	Document lDocument = getDocumentDao().documentVOToEntity(pDocumentVO);
    	DocumentVO lDocumentVO = (DocumentVO) getDocumentDao().create(DocumentDao.TRANSFORM_DOCUMENTVO, lDocument);
        return lDocumentVO.getId();
    }

    /**
     * @see fr.upstlse.glre.business.service.depot.DocumentService#removeDocument(fr.upstlse.glre.business.vo.depot.DocumentVO)
     */
    protected void handleRemoveDocument(fr.upstlse.glre.business.vo.depot.DocumentVO pDocumentVO)
        throws java.lang.Exception
    {
    	Document lDocument = getDocumentDao().documentVOToEntity(pDocumentVO);
    	getDocumentDao().remove(lDocument);
    }

    /**
     * @see fr.upstlse.glre.business.service.depot.DocumentService#updateDocument(fr.upstlse.glre.business.vo.depot.DocumentVO)
     */
    protected void handleUpdateDocument(fr.upstlse.glre.business.vo.depot.DocumentVO pDocumentVO)
        throws java.lang.Exception
    {
    	Document lDocument = getDocumentDao().documentVOToEntity(pDocumentVO);
    	getDocumentDao().update(lDocument);
    }

    /**
     * @see fr.upstlse.glre.business.service.depot.DocumentService#getAllDocuments()
     */
    protected Collection<DocumentVO> handleGetAllDocuments()
        throws java.lang.Exception
    {
        Collection<DocumentVO> lDocuments = getDocumentDao().loadAll(DocumentDao.TRANSFORM_DOCUMENTVO);
        
        return lDocuments;
    }

	@Override
	protected DocumentVO handleGetById(long pDocumentId) throws Exception {
		DocumentVO lDocumentVO = (DocumentVO) getDocumentDao().load(DocumentDao.TRANSFORM_DOCUMENTVO, pDocumentId);
		return lDocumentVO;
	}

	@Override
	protected DocumentVO handleFindByLibelle(LibelleVO pLibelleVO)
			throws Exception {
		Libelle lLibelle = getLibelleDao().libelleVOToEntity(pLibelleVO);
		DocumentVO lDocumentVO = (DocumentVO) getDocumentDao().findByLibelle(DocumentDao.TRANSFORM_DOCUMENTVO, lLibelle);
		return lDocumentVO;
	}

}